package com.tank.aop;

import java.util.HashMap;
import java.util.Map;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

/**
 * Created with IntelliJ IDEA.
 * User: SuQiEr
 * Date:2017/9/30
 * Time: 14:55
 * To change this template use File | Settings | File Templates.
 */
public class MethodTimeActive implements MethodInterceptor {
    /**
     * 自定义map集合，key：方法名，value：[0：运行次数，1：总时间]
     */
    public static Map<String,Long[]> methodTest = new HashMap<String, Long[]>();
    /**
     * 拦截要执行的方法
     */
    public Object invoke(MethodInvocation invocation) throws Throwable {
        // 创建一个计时器
        // 执行方法
        Object object = invocation.proceed();
        // 方法名称
        String methodName = invocation.getMethod().getName();
        System.out.println("方法名称:"+methodName);
        return object;
    }

}